﻿@using System.Data
@{
    ViewBag.Title = "Good";
    Layout = "~/Areas/Admin/Views/Shared/AdminLayout.cshtml";
    DataTable table = ViewData["sort"] as DataTable;
}
<style>
    * {
        overflow: auto;
    }
</style>
<div class="searchpanel">
    <div class="seatchtool">
        <div class="operationtool">
            
        </div>
        <div class="operationsearch">
          
        </div>
    </div>
</div>

<table class="datatable">
    <tr>
        <th width="30">选择<input type="checkbox" id="checkall" /></th>
        <th width="150">订单编号</th>
        <th width="170">支付金额</th>
        <th width="70">用户</th>
        <th width="100">支付时间</th>
        <td></td>
    </tr>
    <tbody id="newslist"></tbody>


</table>
<div id="Pagination" class="pagination" style="">
</div>
<link href="/Scripts/paging/pagination.css" rel="stylesheet" />
<script src="/Scripts/paging/jquery.pagination.js"></script>

<script>
  
    $(function () {
        getlist(0);
        //选择全部
        $("#checkall").click(function () {
            if ($("#checkall").attr("checked")) {
                $("#newslist input[type=checkbox]").attr("checked", "true");
            } else {
                $("#newslist input[type=checkbox]").removeAttr("checked");
            }
        });
    });
    setInterval(function () {
       
        getlist(0);
    }, 5000);
    var pageCount = 10;

    function getlist(pageIndex) {
        $.post("@Url.Action("GetList")", { pageIndex: pageIndex * pageCount, pageCount: pageCount }, function (data) {
            var obj = JSON.parse(data);
            var count = obj.count[0].count;
            var str = "";
            for (var i = 0; i < obj.data.length; i++) {
                var item = obj.data[i];
                str += "<tr><td><input type=\"checkbox\"  value="+item.Id+" /></td>" +
                    "<td>" + item.OrderNo + "</td>" +
                    "<td>" + item.Price + "元</td>" +
                    "<td>" + item.Name + "</td>" +
                    "<td>" + item.Date.replace("T", " ") + "</td>" +
                    "<td></td>" +
                    "</tr>";
            }

            $("#newslist").html(str);

            $("#Pagination").pagination(count, {
                callback: PageCallback,
                prev_text: '上一页', //上一页按钮里text
                next_text: '下一页', //下一页按钮里text
                items_per_page: pageCount, //显示条数
                num_display_entries: 5, //连续分页主体部分分页条目数
                current_page: pageIndex, //当前页索引
                num_edge_entries: 1 //两侧首尾分页条目数
            });

        });
    }
    //分页回调函数
    function PageCallback(index) {
        getlist(index);
    }

</script>

